home *** CD-ROM | disk | FTP | other *** search
- Path: news1.intercall.com!usenet
- From: engevar@intercall.com (Steven Ovits)
- Newsgroups: comp.lang.c
- Subject: Re: modularity and data hiding
- Date: Sat, 30 Mar 1996 23:15:09 GMT
- Organization: Intercall Inc.
- Message-ID: <4jk5mm$9s0@news1.intercall.com>
- References: <4jjvl9$phl@news.bu.edu>
- NNTP-Posting-Host: ts2-111.intercall.com
- X-Newsreader: Forte Free Agent 1.0.82
-
- lachesis@bu.edu (wai yip) wrote:
-
- >hmmm, i seem to be posting here everytime i get a new homework
- >assignment...don't know if it's a good thing. anyway, i seem to have a
-
- No, it's probably not a good thing. Better to talk things out with
- your classmates.
-
- >problem understanding data hiding. i have an assignment which requires me to
- >store 3 letter airport codes in a binary search tree.
- >i have to do it using modularity and data hiding with 5 files(a main file,
- >interface.c file, implementation.c file, interface.h file and an
- >implementation.h file).
-
- >what i don't understand is why i need so many files. in the book i read, they
- >only discussed the necessity for an interface.h file which stores declarations
- >and definitions for prototypes and the implementation.c file which has all the
- >functions for accessing the tree.
-
- You probably wouldn't need so many files in a small project in the
- real world. On the other hand, you do need to know how to use
- several files, so they're teaching you how on a small project.
-
- >so why do i need a .c and .h file for both the implementation and interface
- >files? am i missing some important point in data hiding?
- >hope i don't sound too stupid posting these types of questions ^_^
- >any help would be appreciated.
-
- Let's say you are writing a huge program. You put the binary tree
- code in one souirce (bt.c) file and use the header file (bt.h) to
- access the functions (add, remove, next) by including the header
- (bt.h) in the other source file. One advantage is that you could
- reuse the binary tree code in another program. Another is that
- you may have a dozen of these things in a large program, and it's
- much easier to manage if the code is in separate modules.
-
- Other modules might be used for i/o, for airport-specific functions,
- and for the main program. You might move the program to another
- operating system, and if you're lucky, you could reuse the binary-
- tree and airport code, and even the main program--you'd just have
- to replace the i/o part.
-
- There's more to this, but I'll let one of the language experts
- handle those parts.
-
-